<?php
/**
 * 管理员日志系统模型
 * @author maniac
 */
namespace app\common\service;

use app\common\model\UserLogs AS UserLogsModel;

class UserLogs extends Base
{
    /**
     * 添加管理员日志
     * @param  array $log     日志数据
     * @return int   $id      自增 id
     */
    public function insertLog($log)
    {
        $create = [
            'userid'  => session('userid', '', session_prefix()),
            'module'  => request()->module() ?: 'addons',
            'ip'      => request()->ip(),
            'title'   => $log['title'],
            'content' => isset($log['content']) ? $log['content'] : '',
        ];
        $log = UserLogsModel::create($create);
        return $log->id;
    }
}
